#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/printk.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/timer.h>
static struct timer_list timer1, timer2;
/*
unsigned int jiffies_to_msecs(unsigned long);
unsigned int jiffies_to_usecs(unsigned long);
unsigned long msecs_to_jiffies(unsigned int);
unsigned long usecs_to_jiffies(unsigned int);
*/
void timer1_handler( unsigned long data)
{
	printk("%s : %s\n", __func__, __TIME__);
	mod_timer(&timer1, jiffies + data*HZ);
}
void timer2_handler( unsigned long data)
{
	printk("%s : %s\n", __func__, __TIME__);
	mod_timer(&timer2, jiffies + data*HZ);
}
static int __init timer_init(void)
{
		init_timer(&timer1);
		timer1.data = 4;
		timer1.function = timer1_handler;
		timer1.expires = jiffies + HZ;
		printk("pending0? <%d> \n", timer_pending(&timer1));
		add_timer(&timer1);
		printk("pending1? <%d> \n", timer_pending(&timer1));

		printk("%s\n", __func__);
		printk("pending2? <%d> \n", timer_pending(&timer2));
		setup_timer(&timer2, timer2_handler, 2);
		printk("pending3? <%d> \n", timer_pending(&timer2));
		mod_timer(&timer2, jiffies + msecs_to_jiffies(5000));
		printk("pending4? <%d> \n", timer_pending(&timer2));
        return 0;
}


static void __exit timer_exit(void)
{
	printk("%s\n", __func__);
	del_timer(&timer1);
	del_timer(&timer2);
}

MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Mlo_Lv,Tute-421E-studio");
MODULE_DESCRIPTION("This module is used to conrtol omap3 gpio");

module_init(timer_init);
module_exit(timer_exit);
